]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
endSessionDialog: don't use Tweener for the timer
authorCosimo Cecchi <cosimoc@gnome.org>
Sat, 26 Jan 2013 08:01:41 +0000 (03:01 -0500)
committerCosimo Cecchi <cosimoc@gnome.org>
Fri, 15 Feb 2013 01:42:53 +0000 (20:42 -0500)
We want to make Tweener short-circuit animations when resources are
constrained, so this is not going to work.
Instead, use a one-second timeout until the seconds left reach zero.

https://bugzilla.gnome.org/show_bug.cgi?id=655746

js/ui/endSessionDialog.js

index 59fbae29558d256399fbd42f9e724270a69e16ed..11dbc9d560c1adf44bc0730d98a0016ac90e0eca 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 const Lang = imports.lang;
+const Mainloop = imports.mainloop;
 const Signals = imports.signals;
 
 const AccountsService = imports.gi.AccountsService;
@@ -409,22 +410,34 @@ const EndSessionDialog = new Lang.Class({
     },
 
     _startTimer: function() {
+        let startTime = GLib.get_monotonic_time();
         this._secondsLeft = this._totalSecondsToStayOpen;
-        Tweener.addTween(this,
-                         { _secondsLeft: 0,
-                           time: this._secondsLeft,
-                           transition: 'linear',
-                           onUpdate: Lang.bind(this, this._updateDescription),
-                           onComplete: Lang.bind(this, function() {
-                                           let dialogContent = DialogContent[this._type];
-                                           let button = dialogContent.confirmButtons[dialogContent.confirmButtons.length - 1];
-                                           this._confirm(button.signal);
-                                       }),
-                         });
+
+        this._timerId = Mainloop.timeout_add_seconds(1, Lang.bind(this,
+            function() {
+                let currentTime = GLib.get_monotonic_time();
+                let secondsElapsed = ((currentTime - startTime) / 1000000);
+
+                this._secondsLeft = this._totalSecondsToStayOpen - secondsElapsed;
+                if (this._secondsLeft > 0) {
+                    this._updateDescription();
+                    return true;
+                }
+
+                let dialogContent = DialogContent[this._type];
+                let button = dialogContent.confirmButtons[dialogContent.confirmButtons.length - 1];
+                this._confirm(button.signal);
+
+                return false;
+            }));
     },
 
     _stopTimer: function() {
-        Tweener.removeTweens(this);
+        if (this._timerId != 0) {
+            Mainloop.source_remove(this._timerId);
+            this._timerId = 0;
+        }
+
         this._secondsLeft = 0;
     },